﻿<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Ocean_WPF="clr-namespace:Ocean.OceanFramework.WPF">

    <Style TargetType="{x:Type Ocean_WPF:CustomToolBarButton}">
        <Style.Resources>
            <BooleanToVisibilityConverter x:Key="booleanToVisibilityConverter" />
            <Ocean_WPF:CustomToolBarButtonImageSourceConverter x:Key="customToolBarButtonImageSourceConverter" />

            <!-- Disabled Brushes are used for the Disabled look of each control -->
            <SolidColorBrush x:Key="DisabledForegroundBrush" Color="#888" />
            <SolidColorBrush x:Key="DisabledBackgroundBrush" Color="#EEE" />
            <SolidColorBrush x:Key="DisabledBorderBrush" Color="#AAA" />

            <!-- DefaultedBorderBrush is used to show KeyBoardFocus -->
            <LinearGradientBrush x:Key="DefaultedBorderBrush" EndPoint="0,1" StartPoint="0,0">
                <GradientStop Color="#777" Offset="0.0" />
                <GradientStop Color="#000" Offset="1.0" />
            </LinearGradientBrush>

        </Style.Resources>
        <Setter Property="BorderThickness" Value=".7" />
        <Setter Property="Padding" Value="5" />
        <Setter Property="IsTabStop" Value="False" />

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Ocean_WPF:CustomToolBarButton}">
                    <Border x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
                        <StackPanel Background="#00000000" Orientation="{Binding Path=ButtonLayout, RelativeSource={RelativeSource TemplatedParent}}">
                            <Image x:Name="imgButtonImage" Source="{TemplateBinding EnabledButtonImage}" Stretch="None" VerticalAlignment="Center" Visibility="{Binding Path=ShowButtonImage, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource booleanToVisibilityConverter}}" />
                            <TextBlock x:Name="tbButtonText" Text="{Binding Path=ButtonText, RelativeSource={RelativeSource TemplatedParent}}" Visibility="{Binding Path=ShowButtonText, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource booleanToVisibilityConverter}}" />
                        </StackPanel>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsKeyboardFocused" Value="true">
                            <Setter Property="BorderBrush" Value="{StaticResource DefaultedBorderBrush}" TargetName="Border" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter Property="Foreground" Value="{Binding Path=MouseOverForeground, RelativeSource={RelativeSource TemplatedParent}}" TargetName="tbButtonText" />
                            <Setter Property="BorderBrush" Value="{Binding Path=MouseOverBorder, RelativeSource={RelativeSource TemplatedParent}}" TargetName="Border" />
                            <Setter Property="BorderThickness" Value="0.7" TargetName="Border" />
                            <Setter Property="Background" TargetName="Border" Value="{Binding Path=MouseOverBackground, RelativeSource={RelativeSource TemplatedParent}}" />

                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter Property="Background" Value="{Binding Path=ButtonPressedBackground, RelativeSource={RelativeSource TemplatedParent}}" TargetName="Border" />
                            <Setter Property="BorderBrush" Value="{Binding Path=ButtonPressedBorder, RelativeSource={RelativeSource TemplatedParent}}" TargetName="Border" />
                            <Setter Property="BorderThickness" Value="0.7" TargetName="Border" />
                        </Trigger>

                        <Trigger Property="IsEnabled" Value="false">
                            <!-- ToDo Developers you can uncomment these lines to give the look you want -->
                            <!--<Setter Property="Background" Value="{StaticResource DisabledBackgroundBrush}" TargetName="Border"/>
                            <Setter Property="BorderBrush" Value="{StaticResource DisabledBorderBrush}" TargetName="Border"/>-->
                            <Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}" TargetName="tbButtonText" />
                            <Setter Property="Source" TargetName="imgButtonImage" Value="{Binding Path=DisabledButtonImage, RelativeSource={RelativeSource TemplatedParent}}" />
                        </Trigger>

                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="ShowButtonImage" Value="True" />
                                <Condition Property="ShowButtonText" Value="True" />
                                <Condition Property="ButtonLayout" Value="Horizontal" />
                            </MultiTrigger.Conditions>
                            <MultiTrigger.Setters>
                                <Setter Property="Margin" TargetName="tbButtonText" Value="5,0,0,0" />
                            </MultiTrigger.Setters>
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>
